package code.vista;

import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;

public class JPanelImagen extends JPanel implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -1986932355273632046L;
	private String rutaImagen = "";

	public String getRutaImagen() {
		return rutaImagen;
	}

	public void setRutaImagen(String rutaImagen) {
		this.rutaImagen = rutaImagen;
	}

	public JPanelImagen() {
		super();
		this.setLayout(null);
	}

	public JPanelImagen(String rutaImagen) {
		super();
		this.rutaImagen = rutaImagen;
		this.setLayout(null);
	}

	@Override
	public void paintComponent(Graphics g) {
		if (!this.rutaImagen.equals("")) {
			Image image = new ImageIcon(getClass().getResource(rutaImagen))
					.getImage();
			g.drawImage(image, 0, 0, this.getParent().getWidth(), this
					.getParent().getHeight(), null);
			setOpaque(false);
		}
		super.paintComponent(g);
	}

}